<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/css/sytle.css">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-2.1.4.min.js"></script>
<title>我的需求</title>
<style>
* {
	background: #f6f6f6;
}
</style>
</head>
<body>
	<div class="hgj">
		<div class="page-all">
			<div class="container">
				<!--内容开始-->
				<!--订单头部分类-->
				<header>
					<div class="navbar">
						<div class="navbar-choose">
							<label>需求类型：</label> <select name="order-type" id="status"
								onchange="ref()">
								<option value="0">全部需求</option>
								<option value="1">等待处理</option>
								<option value="2">已接受</option>
								<option value="4">已取消</option>
								<option value="3">已完成</option>
							</select>
						</div>
					</div>
				</header>
				<!--订单列表开始-->

				<div class="odr-list">
					<c:forEach items="${NEED_LIST}" var="need">
						<div class="odr-top">
							<span class="odr-type">${need.wTitle}</span> <span
								class="odr-step"><c:if test="${need.status == 1}">
						等待处理
					</c:if> <c:if test="${need.status == 2}">
						已接受
					</c:if> <c:if test="${need.status == 3}">
						已完成
					</c:if> <c:if test="${need.status == 4}">
						已取消
					</c:if></span> <a href="${pageContext.request.contextPath}/need/getNeed/${need.id}.html" class="odr-more"><img
								src="${pageContext.request.contextPath}/images/right.png" /></a>
						</div>
						<div class="odr-middle">
							<p class="odr-time">
								<img
									src="${pageContext.request.contextPath}/images/odr-time.png" /><span><fmt:formatDate
										value="${need.createTime}" type="BOTH" dateStyle="full" /></span>
							</p>
							<p class="odr-address">
								<img
									src="${pageContext.request.contextPath}/images/odr-address.png" /><span>${need.wAddress}</span>
							</p>
						</div>
						<div class="odr-foot">

							<c:if test="${need.status == 2}">
								<a href="javascript:void();" class="odr-red-btn c_fff" onclick="confirm(${need.id})">确认验收</a>
								<a href="javascript:void();" class="odr-gray-btn xuqiu_cancel" onclick="cancel(${need.id})">取消需求</a>
							</c:if>
							<c:if test="${need.status == 3}">
								<a href="javascript:void();" class="odr-gray-btn xuqiu_delete"
									onclick="showDel(${need.id})">删除需求</a>
							</c:if>
							<c:if test="${need.status == 4}">
								<a href="javascript:void();" class="odr-gray-btn xuqiu_delete"
									onclick="showDel(${need.id})">删除需求</a>
							</c:if>
						</div>
					</c:forEach>
				</div>
			</div>
		</div>
		<footer class="footer-foot">
			<ul class="footer-icon">
				<li><a href="/"><img
						src="${pageContext.request.contextPath}/images/index-icon.png" /><span
						>首页</span></a></li>
				<li><a
					href="${pageContext.request.contextPath}/order/userOrders/0/1.html"><img
						src="${pageContext.request.contextPath}/images/order-icon.png" />
					<span >订单</span></a></li>
				<li><a
					href="${pageContext.request.contextPath}/need/userNeeds/0/1.html"><img
						src="${pageContext.request.contextPath}/images/packets-selected-icon.png" /><span
						class="be-now" >需求</span></a></li>
				<li><a
					href="${pageContext.request.contextPath}/members/accountInfo.html"><img
						src="${pageContext.request.contextPath}/images/mine-icon.png" /><span
						>我的</span></a></li>
			</ul>
		</footer>
		<!--删除需求弹窗-->
		<div class="mask" id="delInfo">
			<div class="popup">
				<h3 class="popup_title bor_r bg_fff">确定要删除需求吗？</h3>
				<div class="popup_choose clearfix bor_r bg_fff">
					<a href="javascript:void();" class="popup_choose_cancel" onclick="closeDelInfo()">取消</a>
					<a href="javascript:void();" class="popup_choose_sure" onclick="del()">确定</a>
				</div>
			</div>
		</div>
	</div>
	<script>
			$(function(){
			   $("#status").val(${status});
		   }); 
		
			function cancel(id) {
				
				$.ajax({
					url : "${pageContext.request.contextPath}/need/cancel/" + id + ".json",
					success : function(data) {
						if (data != 0) {
							window.location.reload();
						}
						//点击后刷新页面
						
					}
				});
			}
			
			function confirm(id) {
				
				$.ajax({
					url : "${pageContext.request.contextPath}/need/confirm/" + id + ".json",
					success : function(data) {
						if (data != 0) {
							window.location.reload();
						}
						//点击后刷新页面
						
					}
				});
			}
	
		function closeDelInfo() {
			$("#delInfo").hide();
		}
		//删除订单
		function showDel(v) {
			id = v
			$("#delInfo").show();
		}
		//删除订单
		function del() {
			$.ajax({
						url : "${pageContext.request.contextPath}/need/del/" + id
								+ ".json",
						success : function(data) {
							if (data != 0) {
								window.location.reload();
							}
						}
					});

		}
	function ref() {
		 var myselect = document.getElementById("status");
		 var index = myselect.selectedIndex;
		 var s = myselect.options[index].value;
		 window.location.href="${pageContext.request.contextPath}/need/userNeeds/" + s + "/1.html"
	}
	</script>
</body>
</html>
